//
//  GStepXmlModel.m
//  helpinrain
//
//  Created by Gang.Wang on 12-7-26.
//  Copyright (c) 2012年 Zhuhai Yuike Technology Co., Ltd. All rights reserved.
//

#import "GStepXmlModel.h"
#import "mcf.h"
#import "ContentItemObject.h"

@implementation GStepXmlModel

@synthesize contents = contents_;

- (void) dealloc
{
    YRelease(contents_)
    [super dealloc];
}



-(id) initWithXmlLocalPath:(NSURL *)xmlLocalPath
{
    self = [super initWithXmlLocalPath:xmlLocalPath];
    if(!self)
    {
        return nil;
    }
    
    [self initWithXmlTree:self.xmlTree];
    
    return self;
}
-(id) initWithXmlTree:(XMLParsedTree *)tree
{
    self = [super initWithXmlTree:tree];
    if(self)
    {        
        self.name = [self.xmlTree attributeValueOfName:@"name" atPath:@"step"];
        self.description = [self.xmlTree attributeValueOfName:@"description" atPath:@"step"];
        
        NSMutableArray * temp_contents = [[NSMutableArray alloc] initWithCapacity:2];
        for (XMLParsedTree * node in [self.xmlTree childrenTreeAtPath:@"step" nodeName:@"content"]) 
        {
            if (!node) 
            {
                continue;
            }
            
            ContentItemObject * content = [[ContentItemObject alloc] initWithXmlTree:node];
            [temp_contents addObject:content];
            YRelease(content)
            
        }
        
        self.contents = temp_contents;
        YRelease(temp_contents)  
    }
    return self;
}


@end
